import axios from 'axios'
import Assert from '../common/Assert.js'

export const CaseSealApplyforService = class CaseSealApplyforService {
    static caseSealApplyforService = null
    requestUrl = 'http://localhost/sealApplyfors'

    static getInstance() {
        if (this.caseSealApplyforService == null) {
            this.caseSealApplyforService = new CaseSealApplyforService()
        }
        return this.caseSealApplyforService
    }
    /**
     * 批量生成文书的方法
     * @param recordFiles
     * @param caseid
     */
    saveBatch(recordFiles, caseid) {
        const params = {}
        params.recordFiles = recordFiles
        params.caseid = caseid
        return axios.post(`${this.requestUrl}/auto`, params)
    }

    /**
     * 添加一个的方法
     * @param caseSealApplyfor
     */
    save(caseSealApplyfor) {
        return axios.post(this.requestUrl, caseSealApplyfor)
    }

    /**
     * 检查的方法
     * @param caseSealApplyfor
     */
    check(caseSealApplyfor) {
        if (!Assert.isNotNull(caseSealApplyfor.applyforUsingTheItem, '请选择用印事项')) {
            return false
        }
        if (!Assert.isNotNull(caseSealApplyfor.caseid, '请选择案件')) {
            return false
        }
        return true
    }

    /**
     * 根据案件查询文书的方法
     * @param id
     */
    getByCaseLaw(id) {
        return axios.get(`${this.requestUrl}/caseLaw/${id}`)
    }

    /**
     * 分页查询
     * @param params
     */
    getByPage(params) {
        return axios.get(`${this.requestUrl}/page`,{
            params
        })
    }

    selectByForm(params){
        return axios.get(`${this.requestUrl}/form`,{
            params:params
        })
    }
}
